feat(avatar): add pf-v6-avatar element#3139
Conversation
Port pf-v5-avatar to pf-v6-avatar with the following v6 API changes: - Replace `border` string attribute (light/dark) with boolean `bordered` attribute, matching React v6 `isBordered` prop - Drop `dark` boolean attribute (removed in v6 React) - Update all CSS custom property tokens from `--pf-v5-c-avatar--*` to `--pf-v6-c-avatar--*` matching the v6 SCSS source - Use v6 global tokens (`--pf-t--global--border--*`) for bordered variant - Simplify placeholder SVG to use `light-dark()` for automatic light/dark mode, replacing the separate dark boolean - Use private CSS custom properties (`--_*`) with public token fallback defaults at use sites - Remove default value from `alt` property to avoid sprouting attributes - Add `aria-hidden="true"` to placeholder SVG - Add `@cssprop` JSDoc for all public CSS custom properties - Export `AvatarSize` type union Demos match patternfly.org: basic, bordered, size-variations. Tests cover sizes (offsetWidth), load event, alt text (a11ySnapshot), bordered, and placeholder rendering. Closes #2979 Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use `static styles = [style]` array form convention - Simplify render return type to TemplateResult - Change img/svg display from inline to block (prevents baseline gap) - Add placeholder avatar to basic demo - Add a11ySnapshot test for placeholder hidden from ax tree - Add size=md test case - Strengthen bordered test assertion (check border adds to size) - Add cem generate output path to config Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
|
✅ Commitlint tests passed!More Info{
"valid": true,
"errors": [],
"warnings": [],
"input": "feat(avatar): add pf-v6-avatar element"
} |
✅ Deploy Preview for patternfly-elements ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
bennypowers
left a comment
There was a problem hiding this comment.
needs a changeset
this isn't an 'add', it's an "update", so delete v5, and make the commit message feat(avatar)!: port to pf-v6-avatar
| @@ -1,5 +1,6 @@ | |||
| sourceControlRootUrl: https://github.com/patternfly/patternfly-elements/tree/main/ | |||
| generate: | |||
| output: ./elements/custom-elements.json | |||
| "./pf-v5-accordion/pf-v5-accordion.js": "./pf-v5-accordion/pf-v5-accordion.js", | ||
| "./pf-v5-alert/pf-v5-alert.js": "./pf-v5-alert/pf-v5-alert.js", | ||
| "./pf-v5-avatar/pf-v5-avatar.js": "./pf-v5-avatar/pf-v5-avatar.js", | ||
| "./pf-v6-avatar/pf-v6-avatar.js": "./pf-v6-avatar/pf-v6-avatar.js", |
There was a problem hiding this comment.
we can probably remove all of these, since mappa handles trailing-slash exports
| * or a placeholder graphic. | ||
| * @summary Displays a user's avatar image | ||
| * @fires {PfV6AvatarLoadEvent} load - when the avatar image loads | ||
| * @cssprop {<length>} --pf-v6-c-avatar--Width - Width of the avatar |
Summary
<pf-v6-avatar>web component for PatternFly v6srcis providedsize(sm/md/lg/xl),bordered,alt, andsrcattributesPfV6AvatarLoadEventwhen image loadslight-dark()fallbacksCloses #2979
Depends on #3130
Intentional divergences from React
<img>(withsrcdefaulting to empty string). Our web component renders an inline SVG placeholder whensrcis not provided, avoiding a network request and enabling CSS-based theming of the placeholder via--pf-t--global--background--color--200and--pf-t--global--icon--color--subtledesign tokens. This is a net-new feature not present in React.borderedattribute instead of React'sisBordered(nois-prefix per ADVICE.md)altis optional (defaults to""decorative image); React requiresalt: stringloadevent added (PfV6AvatarLoadEvent) — not in ReactTest plan
npm run testpasseslocalhost:8000with?rendering=chromelesssrcdisplays image; withoutsrcdisplays placeholder SVGaria-hidden="true")Assisted-By: Claude noreply@anthropic.com